import React, { useState } from "react";
import Navbar from "../../components/NavBar";
import MyCarousel from "../../components/Carousel";
import BulletinBoard from "../../components/BulletinBoard";
import { TAnnouncements } from "../../components/BulletinBoard/type";
import { getNotice } from "../../server/api";
const Home: React.FC = ({}) => {
  const [announcements, setAnnouncements] = useState<TAnnouncements[]>([]);

  const handleChange = (current: number) => {
    setPagination({ ...pagination, current });
  };
  const [pagination, setPagination] = useState({
    total: 0,
    pageSize: 5,
    current: 1,
  });
  const getBBData = async () => {
    const res: any = await getNotice({
      pageNum: pagination.current,
      pageSize: pagination.pageSize,
    });
    setPagination({ ...pagination, total: res.total });
    setAnnouncements(res.records);
  };
  return (
    <div>
      <Navbar></Navbar>
      <MyCarousel />
      <BulletinBoard
        announcements={announcements}
        pagination={pagination}
        handleChange={handleChange}
        getBBData={getBBData}
        isShow={false}
      />
    </div>
  );
};
export default Home;
